package cn.wolfcode.p2p.mgrsite.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.wolfcode.p2p.base.exception.DisplayableException;
import cn.wolfcode.p2p.base.query.VideoAuthQueryObject;
import cn.wolfcode.p2p.base.service.IVideoAuthService;
import cn.wolfcode.p2p.base.util.JSONResult;

/**
 * 后台视频认证控制器
 * 
 * @author wolfcode
 *
 */
@Controller
public class VideoAuthController {

	@Autowired
	private IVideoAuthService authService;

	@RequestMapping("vedioAuth")
	public String videoAuthList(@ModelAttribute("qo") VideoAuthQueryObject qo, Model model) {
		model.addAttribute("pageResult", this.authService.query(qo));
		return "vedioAuth/list";
	}

	/**
	 * 视频审核
	 */
	@RequestMapping("vedioAuth_audit")
	@ResponseBody
	public JSONResult audit(Long id,String remark,int state){
		JSONResult result = new JSONResult();
		try {
			this.authService.audit(id,state,remark);
		} catch (DisplayableException ex) {
			result = new JSONResult(false, ex.getMessage());
		} catch (Exception e) {
			// 把错误信息记录到服务器中日志文件中,方便排查问题.
			result = new JSONResult(false, "系统异常,请联系管理员!");
			e.printStackTrace();
		}
		return result;
	}

}
